package com.ruyuan.eshop.data.migrate.tool.service.impl;

import com.ruyuan.eshop.data.migrate.tool.mapper.origindb.OriginAfterSaleRefundMapper;
import com.ruyuan.eshop.data.migrate.tool.model.order.AfterSaleRefundDO;
import com.ruyuan.eshop.data.migrate.tool.service.OriginAfterSaleRefundService;
import com.ruyuan.eshop.data.migrate.tool.util.LoggerFormat;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author zhonghuashishan
 * @version 1.0
 */
@Slf4j
@Service
public class OriginAfterSaleRefundServiceImpl implements OriginAfterSaleRefundService {

    @Autowired
    private OriginAfterSaleRefundMapper originAfterSaleRefundMapper;

    @Override
    public List<AfterSaleRefundDO> list(Long minId, Date lastGmtModified, int batchSize) {
        log.info(LoggerFormat.build()
                .remark("list->request")
                .data("minId", minId)
                .data("lastGmtModified", lastGmtModified)
                .data("batchSize", batchSize)
                .finish());

        // 基于最小订单ID查询一批数据
        List<AfterSaleRefundDO> afterSaleRefundDOList = originAfterSaleRefundMapper.list(minId, lastGmtModified, batchSize);

        log.info(LoggerFormat.build()
                .remark("list->response")
                .data("afterSaleRefundDOList", afterSaleRefundDOList)
                .finish());

        return afterSaleRefundDOList;
    }
}